// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
Vue.use(BootstrapVue);
import App from "./App";
import router from "./router";
import BootstrapVue from "bootstrap-vue";
import axios from "axios";
import "bootstrap-vue/dist/bootstrap-vue.css";
import "bootstrap/dist/css/bootstrap.css";
//ui
import { InfiniteScroll } from "mint-ui";
import "mint-ui/lib/style.css";

Vue.use(InfiniteScroll);

//后台css
require("./assets/css/backstage/themes.css");
require("./assets/css/backstage/pixel-admin.css");

//baseURL
// axios.defaults.baseURL = '/api';

Vue.config.productionTip = false;
Vue.prototype.$axios = axios;

//响应拦截器
axios.interceptors.response.use(
  res => {
    // console.log(res.config.url + ' ------>', res.data);
    return res;
  },
  function(error) {
    console.log(error);
    return error;
  }
);

/* eslint-disable no-new */
new Vue({
  el: "#app",
  router,
  components: { App },
  template: "<App/>"
});

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  if (to.name === "BackStage") {
    if (sessionStorage.getItem("logo") === "true") {
      next();
    } else {
      next({
        path: "/logo"
      });
    }
  } else {
    next();
  }
});
